package com.example.blog.util;

import com.example.blog.config.page.PageRequest;
import com.example.blog.config.page.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;

/**
 * @Author: lu
 * @Date: 2023-09-09-11:13
 * @Description: 分页工具类
 */
public class PageUtil {

    /**
     * 对分页返回的数据处理
     * @param pageRequest
     * @param pageInfo
     * @return
     */

    public static PageResult getPageResult(PageRequest pageRequest, PageInfo<?> pageInfo) {
        PageResult pageResult = new PageResult();
        pageResult.setPageNum(pageInfo.getPageNum());
        pageResult.setPageSize(pageInfo.getPageSize());
        pageResult.setTotalSize(pageInfo.getTotal());
        pageResult.setTotalPages(pageInfo.getPages());
        pageResult.setResult(pageInfo.getList());
        return pageResult;

    }
}
